package com.tzy.tzyrpccore.conf;

import com.tzy.tzyrpccore.consumer.ConsumerBootStrap;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

/**
 * @author caituxinchu
 */
@Configuration
public class ConsumerConf {

  @Bean
    public ConsumerBootStrap consumerBootStrap(){
      return new ConsumerBootStrap();
  }

  @Bean  //扫描配置类注入Bean时就运行该方法
  @Order(Integer.MIN_VALUE)// 值最小，优先级最高,保证当前ApplicationRunner先运行
  public ApplicationRunner runScreenConsumerServiceFields(ConsumerBootStrap consumerBootStrap){
    // ApplicationRunner同一个应用程序上下文可以有多个，函数式接口，run方法 用于运行Bean的回调

     return x-> consumerBootStrap.screenConsumerServiceFields();
  }
}
